package zxk.spider.webmagic.pipline;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import us.codecraft.webmagic.ResultItems;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.pipeline.Pipeline;
import zxk.spider.domain.MovieEntity;
import zxk.spider.mapper.MovieMapper;

@Slf4j
@RequiredArgsConstructor
@Component
public class MyPipeline implements Pipeline {

    private final MovieMapper movieMapper;

    @Override
    public void process(ResultItems resultItems, Task task) {
        MovieEntity tvInfo = resultItems.get("tvInfo");
        if (tvInfo!=null){
            movieMapper.insert(tvInfo);
        }
    }
}